package org.hawk.gwtppc.webtest.tests.classsuite;

import java.lang.reflect.Modifier;
import java.util.Arrays;

import org.hawk.gwtppc.webtest.common.Asserts;
import org.hawk.gwtppc.webtest.common.Test;
import org.hawk.gwtppc.webtest.tests.mock.SubClassMock2;

public class GetDeclaredMethodsTest implements Test {

	public void run() throws Throwable {
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods().length, 4, "Expected array of length 4 but got " +
				SubClassMock2.class.getDeclaredMethods().length + ": " + Arrays.toString(SubClassMock2.class.getDeclaredMethods()));
		
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[0].toString(), 
				"public void org.hawk.gwtppc.webtest.tests.mock.SubClassMock2.processValue()");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[0].getModifiers(), Modifier.PUBLIC);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[0].getReturnType(), void.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[0].getParameterTypes().length, 0);

		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[1].toString(), 
				"protected final int org.hawk.gwtppc.webtest.tests.mock.SubClassMock2.processValue(int)");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[1].getModifiers(), Modifier.PROTECTED | Modifier.FINAL);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[1].getReturnType(), int.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[1].getParameterTypes().length, 1);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[1].getParameterTypes()[0], int.class);
		
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[2].toString(), 
				"java.lang.Object org.hawk.gwtppc.webtest.tests.mock.SubClassMock2.processValue(int,java.lang.Object)");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[2].getModifiers(), 0);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[2].getReturnType(), Object.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[2].getParameterTypes().length, 2);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[2].getParameterTypes()[0], int.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[2].getParameterTypes()[1], Object.class);
		
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[3].toString(), 
				"private static org.hawk.gwtppc.webtest.tests.mock.SubClassMock2 org.hawk.gwtppc.webtest.tests.mock." +
						"SubClassMock2.processValue(int,java.lang.Object,org.hawk.gwtppc.webtest.tests.mock.SubClassMock2)");
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[3].getModifiers(), Modifier.PRIVATE | Modifier.STATIC);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[3].getReturnType(), SubClassMock2.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[3].getParameterTypes().length, 3);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[3].getParameterTypes()[0], int.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[3].getParameterTypes()[1], Object.class);
		Asserts.assertEquals(SubClassMock2.class.getDeclaredMethods()[3].getParameterTypes()[2], SubClassMock2.class);
	}

	public String getName() {
		return "getDeclaredMethods()";
	}

}
